# -*- coding:UTF-8 -*-
import logging,os

class JKLogger():
    def __init__(self, fileName):

        self.logger = logging.getLogger(fileName)
        if not os.path.exists('log/'):
            os.makedirs('log')

        self.logger.setLevel(logging.DEBUG)


        self.fh = logging.FileHandler('log/{0}.log'.format(fileName))
        self.fh.encoding = "utf-8"
        self.ch = logging.StreamHandler()

        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        self.fh.setFormatter(formatter)
        self.ch.setFormatter(formatter)

        self.logger.addHandler(self.fh)
        self.logger.addHandler(self.ch)


    def delLogger(self):
        self.logger.removeHandler(self.ch)
        self.logger.removeHandler(self.fh)


    def log(self, something):
        self.logger.debug(something)